package com.yf.system.config.shiro;

import com.yf.ability.system.shiro.dto.SysUserLoginDTO;
import com.yf.ability.system.shiro.utils.ShiroDataGetter;
import com.yf.system.modules.sys.menu.service.SysMenuService;
import com.yf.system.modules.sys.user.service.SysUserRoleService;
import com.yf.system.modules.sys.user.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 数据获取实现类
 * @author bool
 */
@Component
public class ShiroDataGetterImpl implements ShiroDataGetter {


    @Autowired
    @Lazy
    private SysUserService sysUserService;

    @Autowired
    @Lazy
    private SysUserRoleService sysUserRoleService;

    @Autowired
    @Lazy
    private SysMenuService sysMenuService;


    @Override
    public List<String> listRoles(String userId) {
        return sysUserRoleService.listRoleIds(userId);
    }

    @Override
    public List<String> listPermissions(String userId) {
        return sysMenuService.findPermissions(userId);
    }

    @Override
    public SysUserLoginDTO checkToken(String token) {
        return sysUserService.token(token);
    }
}
